package com.yougong.api.modules.customer.service.impl;

import com.yougong.api.modules.customer.model.dto.CaptchaDTO;
import com.yougong.api.modules.customer.service.CusCacheService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.cache.annotation.CacheConfig;
import org.springframework.cache.annotation.CacheEvict;
import org.springframework.cache.annotation.CachePut;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.stereotype.Service;

@Slf4j
@Service
@CacheConfig(cacheNames = "cus_cache")
public class CusCacheServiceImpl implements CusCacheService {

    @Override
    @CachePut(key = "#captchaDTO.captchaId")
    public CaptchaDTO setCache(CaptchaDTO captchaDTO) {
        log.info("captcha value is: "+captchaDTO.getCaptchaValue());
        log.info("captcha key is:" + captchaDTO.getCaptchaId());
        log.info("存储验证码信息");
        return captchaDTO;
    }

    @Override
    @Cacheable(key = "#captchaId")
    public CaptchaDTO getCache(String captchaId) {
        log.info("没有缓存");
        return null;
    }

    @Override
    @CacheEvict(key = "#captchaId")
    public void delCache(String captchaId) {
    }
}
